/**
 * Copyright 2024/3/24 the original brandnewdata.com.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * https://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.zlb.envmodify.example;

import java.util.Properties;

/**
 * @Description 修改java.util.Properties的setProperty的方法
 * @Warning Properties是在转换器生效钱就提前加载的，因此没办法通过 setProperties$agent的方式调用原来的方法
 * @ClassName PropertiesPutMethodExample
 * @Author zhulb
 * @Date 2024/3/24 13:29
 * @Version 0.0.1
 */
public class SetPropertiesMethodExample {
    /**
     * 请在配置vm option，路径按照实际情况设置
     * -Dlogging.level.root=INFO -javaagent:D:\code_zlb\zlb-java-envmodify\target\zlb-java-envmodify-2.8.9-release-jar-with-dependencies.jar
     * @param args
     */
    public static void main(String[] args) {
        /**
         * 效果
         * 原来：原来的方法setProperty过程不输出任何内容
         * 插件：使用插件后，将输出类名和setProperty的详细信息
         * 需要在envmodify.config中放开相应的注释，然后重新package
         */
        Properties properties = new Properties();
        properties.setProperty("zhulb","33");

        SetPropertiesMethodExample setPropertiesMethodExample = new SetPropertiesMethodExample();
        setPropertiesMethodExample.subProperties();
    }

    private void subProperties() {
        SubProperties subProperties = new SubProperties();
        subProperties.setProperty("zhulb","33");
    }

    class SubProperties extends Properties {
        public SubProperties(){
            super();
        }
    }

}
